#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
long n,q,a[8001],b,c,d;
int u(int t)
{
	for(int k=0;k<n;k++)
	{
		if(a[k]==t)
		  return k;
	}
}
int main()
{
	freopen("sort.in","r",stdin);
	freopen("sort.out","w",stdout);
	cin>>n>>q;
	for(int i=1;i<=n;i++)
	  cin>>a[i];
	for(int i=1;i<=q;i++)
	{
		cin>>b;
		if(b==2)
		{
			cin>>c;
			for(int j=1;j<=n;j++)
			   if(a[j]==c)
			     cout<<j<<endl;
		}
		if(b==1)
		{
			cin>>c>>d;
			swap(a[u(c)],a[u(d)]);
		}
	}
	fclose(stdin);
	fclose(stdout);
	return 0;
}
